package org.batatasframework.chart.columns;

/**
 * 这个是百分比的值
 * @author jackson
 *
 */
public class ArithmeticDecimal {
	
	private double oneValue;
	private double twoValue;
	
	public ArithmeticDecimal(double oneValue, double twoValue){
		this.oneValue = oneValue;
		this.twoValue = twoValue;
	}
	
	public ArithmeticDecimal add(ArithmeticDecimal dec){
		this.oneValue += dec.oneValue;
		this.twoValue += dec.twoValue;
		return this;
	}
	
	public Double percent(){
		if(twoValue == 0) return null;//分母为0，无法计算
		return Double.valueOf(oneValue / twoValue * 100);
	}
	
	public Double division(){
		if(twoValue == 0) return null;//分母为0，无法计算
		return Double.valueOf(oneValue / twoValue);
	}
	
	public Double multiplication(){
		return Double.valueOf(oneValue * twoValue);
	}
	
	public Double sum(){
		return Double.valueOf(oneValue + twoValue);
	}
}
